// 首页相关接口
import request from "@/utils/request.js";


//获取作品详细信息
export function getWorkDetail(id,workType) {
	if(workType==1){
		return request.get(`work/detail/${id}`);
	}else{
		return request.get(`/work/draft/detail/${id}`);
	}
}

//获取评论列表
export function getCommonList(workId, pid, page, limit,workType) {
	return request.get(`work/common/list?workId=${workId}&pid=${pid}&page=${page}&limit=${limit}&workType=${workType}`);
}

//点赞作品
//id 作品id
export function workLikeAdd(id,workType) {
	return request.post('work/like/add', {
		id,
		workType
	});
}

//取消点赞作品
//id 作品id
export function workLikeDel(id,workType) {
	return request.post('work/like/del', {
		id,
		workType
	});
}

//关注用户
//userId 用户id
export function followUser(userId) {
	return request.get(`work/user/follow/${userId}`);
}

//取消关注用户
//userId 用户id
export function cancelFollowUser(userId) {
	return request.get(`work/user/cancel_follow/${userId}`);
}

//评论作品
export function sendCommentWork(workId, comment,workType) {
	return request.post('work/send_comment', {
		workId,
		comment,
		workType
	});
}

//回复评论
// reply_comment_id string 回复的评论id
// comment string 回复内容
export function replyComment(reply_comment_id, comment) {
	return request.post('work/reply_comment', {
		reply_comment_id,
		comment
	});
}

//点赞评论
//id 评论id
export function commentLikeAdd(id,workType) {
	return request.post('work/comment_like/add', {
		id,
		workType
	});
}


//取消评论点赞
//id 评论id
export function commentLikeDel(id) {
	return request.post('work/comment_like/del', {
		id
	});
}



//获取设计师首页待处理列表
//page 
//limit
export function getDesignerPendingWork(page, limit) {
	return request.get(`work/designer/pending_work?page=${page}&limit=${limit}`);
}


//设计师接受或者拒绝待处理作品
//workId 作品id
//status 操作状态 0拒绝 1接受
export function processWork(workId, status) {
	return request.post('work/designer/process', {
		workId,
		status
	});
}


//获取设计师处理过的作品列表
//status 状态 0已拒绝 1设计中 2已定稿
// page
// limit
export function getDraftWork(status, page, limit) {
	return request.get(`work/designer/draft_work?status=${status}&page=${page}&limit=${limit}`);
}

//获取设计师设计作品历史
//draftId 设计师接受记录id
export function getDraftHistory(draftId) {
	return request.get(`work/designer/draft_list?draftId=${draftId}`);
}


//设计师发布初稿
//draftId 设计师作品记录id
// content 初稿内容描述文字
// images 初稿图片数组
//title 初稿标题
export function publishDraft(draftId, content, images,title) {
	return request.post('work/designer/publish_draft', {
		draftId,
		content,
		images,
		title
	});
}



//获取作品列表
//keyword 搜索字段
//is_recommend 是否要筛选设置了推荐的作品 1是 0否
//is_follow 是否关注
//page
//limit
//不需要登录就可加载
export function getWorkList(keyword, page, limit, is_follow, is_recommend) {
	return request.get(
		`work/list?keyword=${keyword}&is_follow=${is_follow}&page=${page}&limit=${limit}&is_recommend=${is_recommend}`,{}, {
			noAuth: true
		});
}


//分享作品后请求
//work_id 作品id
export function shareWork(work_id,workType) {
	return request.get(`work/share/${work_id}/${workType}`);
}


//共创中心设计稿列表
//keyword 搜索关键字
//page
//limit
export function getDraftList(keyword,page,limit) {
	return request.get(`work/draft/list?keyword=${keyword}&page=${page}&limit=${limit}`);
}


//获取作品关联设计稿列表
//workId 作品id
//page
//limit
export function getDrafRelation(workId,page,limit) {
	return request.get(`work/draft/relation/list?workId=${workId}&page=${page}&limit=${limit}`);
}


//获取设计作品 历史稿件
//workId 作品id
//page
//limit
export function getdraft_list(draftId,page,limit) {
	return request.get(`work/designer/draft_list?draftId=${draftId}&page=${page}&limit=${limit}`);
}


//稿件想要或者取消想要
export function setWantValue(id, workType, want) {
	if(want){
		return request.post('work/want/add', {
			id,
			workType
		});
	}else{
		return request.post('work/want/del', {
			id,
			workType
		});
	}
}


//获取我的团队
//page
//limit
export function getTeam_list(page,limit) {
	return request.get(`work/user/team_list?page=${page}&limit=${limit}`);
}

//获取我的收益
export function getTeam_profit(year) {
	return request.get(`work/user/profit/log?year=${year}`);
}